package ru.spbau.database.group3.engine;

import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import ru.spbau.database.group3.index.IndexKeyType;

public class BTreeIndexInfo implements Serializable{

	private IndexKeyType keyType;
	private String indexFileName;
	
	public BTreeIndexInfo(IndexKeyType keyType, String indexFileName) {
		this.keyType = keyType; 
		this.indexFileName = indexFileName;
	}
	
	public boolean isSuitable(List<Condition> conditions, List<Column> relationColumns) {
		Set<Column> columns = new HashSet<Column>();
		for (Condition c : conditions) {
			columns.add(c.getColumn());
		}
		return keyType.equals(new IndexKeyType(columns, relationColumns));
	}
	
	public String getIndexName() {
		return indexFileName;
	}
}
